package jsi.search;

import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.util.Set;

import org.apache.lucene.analysis.LowerCaseFilter;
import org.apache.lucene.analysis.StopFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.analysis.standard.StandardFilter;
import org.apache.lucene.analysis.standard.StandardTokenizer;

public class PolishAnalyzer extends StandardAnalyzer {

	public PolishAnalyzer() {
		super();
	}

	public PolishAnalyzer(Set stopWords) {
		super(stopWords);
	}

	public PolishAnalyzer(String[] stopWords) {
		super(stopWords);
	}

	public PolishAnalyzer(File stopwords) throws IOException {
		super(stopwords);
	}

	public PolishAnalyzer(Reader stopwords) throws IOException {
		super(stopwords);
	}
/*
	@Override
	public TokenStream tokenStream(String fieldName, Reader reader) {
		TokenStream result = super.tokenStream(fieldName, reader);
		
		result = new PolishWordsFilter(result);
		
		return result;
	}
*/
	/** Constructs a {@link StandardTokenizer} filtered by a {@link
	  StandardFilter}, a {@link LowerCaseFilter} and a {@link StopFilter}. */
	  public TokenStream tokenStream(String fieldName, Reader reader) {
	    StandardTokenizer tokenStream = new StandardTokenizer(reader, false);
	    tokenStream.setMaxTokenLength(getMaxTokenLength());
	    TokenStream result = new StandardFilter(tokenStream);
	    result = new LowerCaseFilter(result);
	    result = new PolishWordsFilter(result);
	  //  result = new StopFilter(result, stopSet); 
	    return result;
	  }
	  
	  public TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException {
		  TokenStream result = super.reusableTokenStream(fieldName, reader);
		  result = new PolishWordsFilter(result);
		  return result;
	  }
}
